import {search_detail} from '@/network/api'
import http from '@/network/http'
export default{
  namespaced:true,
  state:{
    userInfo:null,uid:null,
    likeSong:null
  },
  mutations:{
    setUserInfo(state,payload){
      state.userInfo=payload
      // state.uid=payload.userId
    },
    setLikeSong(state,payload){
      state.likeSong=payload
    }
  },
  actions:{
    async getLikeSong(context,payload){
      let { songs } = await http.get(search_detail, payload);
      songs = songs.map((item) => ({
        id: item.id, //id
        title: item.name, //歌名
        ar: item.ar.map((arItem) => arItem.name), //歌手
        al: {
          //专辑
          name: item.al.name,
          picUrl: item.al.picUrl,
        }
      }))
      context.commit('setLikeSong',songs)
    }
  }
}